/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package FrameWork;

import java.io.IOException;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.Sprite;

/**
 *
     * @author DANTRUONG
 */
public class RSMainGame {
    private static RSMainGame instance = null;
    public static RSMainGame getRS (){
         if( instance == null){
             instance =  new RSMainGame();
         }
         return instance;
    }
    
    private RSMainGame (){
        
        m_Process = 0;
        m_Total = 5;
        m_iComplete = false;
    }
    private boolean m_iComplete; // Init complete?
    private int m_Process;  // Process init
    private int m_Total;    // total sprite
    
   
    private Sprite m_Item;  //8
    private Sprite m_House; //9
    private Sprite m_Elefire; //10
    private Sprite m_Fire;
    private Sprite m_UI;
    
    public int Init () {
        if (!m_iComplete){
                try{
                switch (m_Process){
                case 0:
                    m_Item = new Sprite (
                        Image.createImage("/Image/item.png"),
                        30, 30);
                    break;  
                case 1:
                   m_House = new Sprite 
                            (Image.createImage("/Image/house.png")
                            ,90 ,90);
                    break;
                case 2:
                    m_Elefire =  new Sprite 
                            (Image.createImage("/Image/enemy.png")
                            ,30,30);
                    break;
                    case 3:
                    m_Fire = new Sprite (
                        Image.createImage("/Image/fire.png"),
                        20, 40);
                    break;
//                case 3:
//                    m_Fire = new Sprite (
//                        Image.createImage("/Image/fire.png"),
//                        40, 40);
//                    break;
                case 4:
                    m_UI = new Sprite (
                        Image.createImage("/Image/ui.png"),
                        240, 50);
                    break;
                
                }
            } catch (final IOException ex) {
                ex.printStackTrace();
            }
            m_Process++;
        }       
        
        if ( m_Process== m_Total){
            m_iComplete = true;
            return -1;
        }
        return m_Process;
        
    }
    
    public Sprite getItem (){
        if (!m_iComplete)  return null;
        return m_Item;
    }
    
    public Sprite getElefire (){
        if (!m_iComplete)  return null;
        return m_Elefire;
    }
    
    public Sprite getHouse (){
        if (!m_iComplete)  return null;
        return m_House;
    }
    
//    public Sprite getFire (){
//         if (!m_iComplete)  return null;
//        return m_Fire;
//    }
    public Sprite getFire (){
         if (!m_iComplete)  return null;
        return m_Fire;
    }
    
    public Sprite getUI (){
         if (!m_iComplete)  return null;
        return m_UI;
    }
    public void Release (){
       
    }
}
